home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7859 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: malloc() problem
  5. Date: 27 Feb 1996 15:35:49 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h04glINNert@anvil.ugrad.cs.ubc.ca>
  8. References: <31332992.41C6@mashie.ece.jhu.edu>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <31332992.41C6@mashie.ece.jhu.edu>,
  12. Chenyang Xu  <chenyang@mashie.ece.jhu.edu> wrote:
  13. >Hi, there,
  14. >
  15. >    Recently I have been haunted by the core dump inside malloc() on SGI
  16. >Indigo2 IRIX5.2, I know the problem is caused by my program not the
  17. >malloc(). But I couldn't find the bug? Does any C expert has identified 
  18. >the common reasons for malloc to core dump? Your help will probably help
  19. >me to find the  bug. Thank you very much!
  20.  
  21. Use a Malloc debugger. Try ElectricFence. It was developed a number of years
  22. ago at Pixar. It works under an assortment of UNIX operating systems.
  23.  
  24. It works by replacing the malloc() routines with its own routines which place
  25. protected pages around allocation blocks. When your program overruns the
  26. boundaries of a block, it causes a segmentation violation immediately, so you
  27. know where the _real_ error happens.
  28.  
  29. I learned about ElectricFence one morning at 6:00 am after I spent the whole
  30. night chasing a pointer bug. I untarred the thing, compiled it, linked the
  31. "libefence.a" library to my program and found the bug in three seconds.
  32.  
  33. When your program is linked with EF, you can control through environment
  34. variables whether the ends of blocks are aligned on page boundaries or the
  35. beginnings, to detect overruns or underruns precisely (can't do both,
  36. obviously). You can also arrange for all free()d memory to be protected---this
  37. can use a lot of virtual memory on your machine!
  38. -- 
  39.  
  40.